<?php

namespace App\Http;

use App\Http\Middleware\AdminAuth\AdminRequestMiddleware;
use App\Http\Middleware\Approval\ApprovalMiddleware;
use App\Http\Middleware\Approval\ApprovalTemplateLegitimacyMiddleware;
use App\Http\Middleware\Auth\AuthRoleLegitimacyMiddleware;
use App\Http\Middleware\Auth\BulkyAuthMiddleware;
use App\Http\Middleware\Auth\RequestMiddleware;
use App\Http\Middleware\Auth\RoleLegitimacyMiddleware;
use App\Http\Middleware\Client\ClientLegitimacyMiddleware;
use App\Http\Middleware\Company\CompanyLegitimacyMiddleware;
use App\Http\Middleware\Contract\ContractCodeLegitimacyMiddleware;
use App\Http\Middleware\Contract\ContractFormatTempLegitimacyMiddleware;
use App\Http\Middleware\Contract\ContractTempLegitimacyMiddleware;
use App\Http\Middleware\Contract\ContractTypeLegitimacyMiddleware;
use App\Http\Middleware\Contract\RiskElementLegitimacyMiddleware;
use App\Http\Middleware\CreditProject\CreditProjectLegitimacyMiddleware;
use App\Http\Middleware\Department\DepartmentLegitimacyMiddleware;
use App\Http\Middleware\Login\LoginLegitimacyMiddleware;
use App\Http\Middleware\LogMiddleware;
use App\Http\Middleware\Position\PositionLegitimacyMiddleware;
use App\Http\Middleware\Staff\StaffLegitimacyMiddleware;
use App\Http\Middleware\TenderBid\BusinessTypeLegitimacyMiddleware;
use App\Http\Middleware\TenderBid\TenderTypeLegitimacyMiddleware;
use App\Http\Middleware\XSS;
use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array<int, class-string|string>
     */
    protected $middleware = [
        // \App\Http\Middleware\TrustHosts::class,
        \App\Http\Middleware\TrustProxies::class,
        \Fruitcake\Cors\HandleCors::class,
        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,

    ];

    /**
     * The application's route middleware groups.
     *
     * @var array<string, array<int, class-string|string>>
     */
    protected $middlewareGroups = [
            'web' =>	[
                            \App\Http\Middleware\EncryptCookies::class,
                            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
                            \Illuminate\Session\Middleware\StartSession::class,
                            // \Illuminate\Session\Middleware\AuthenticateSession::class,
                            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
                            \App\Http\Middleware\VerifyCsrfToken::class,
                            \Illuminate\Routing\Middleware\SubstituteBindings::class,
                        ],

            'api' =>	[
                            XSS::class,
                            RequestMiddleware::class,
                            LogMiddleware::class,
                             \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
                            'throttle:api',
                            \Illuminate\Routing\Middleware\SubstituteBindings::class,

                            #
                            #
//                            \App\Http\Middleware\c_middleware_verify_user_visit_permission::class,
                        ],
            'adx' => [
                XSS::class,
                AdminRequestMiddleware::class
            ]
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array<string, class-string|string>
     */
    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

        // 审批中间件
        'approvalMiddleware' =>ApprovalMiddleware::class,
        // 权限中间件
        'bulkAuth' => BulkyAuthMiddleware::class,
        // 合法验证中间件
//        'companyLeg' => CompanyLegitimacyMiddleware::class,
//        'departmentLeg' => DepartmentLegitimacyMiddleware::class,
        'positionLeg' => PositionLegitimacyMiddleware::class,
        'staffLeg' => StaffLegitimacyMiddleware::class,
        'loginLeg' => LoginLegitimacyMiddleware::class,
        'clientLeg' => ClientLegitimacyMiddleware::class,
        'contractTypeLeg' => ContractTypeLegitimacyMiddleware::class,
        'tenderPatternLeg' => TenderTypeLegitimacyMiddleware::class,
        'businessTypeLeg' => BusinessTypeLegitimacyMiddleware::class,
        'contractTempLeg' => ContractTempLegitimacyMiddleware::class,
        'contractFormatTempLeg' => ContractFormatTempLegitimacyMiddleware::class,
        'creditProjectLeg' => CreditProjectLegitimacyMiddleware::class,
        'riskElementLeg' => RiskElementLegitimacyMiddleware::class,
        'contractCodeLeg' => ContractCodeLegitimacyMiddleware::class,
//        'approvalTemplateLeg' => ApprovalTemplateLegitimacyMiddleware::class,
        'roleLeg' => RoleLegitimacyMiddleware::class,
        'authRoleLeg' => AuthRoleLegitimacyMiddleware::class,


    ];
}
